<template>
	<view class="">
		<view class="navBar" :style="`padding-top: ${statusBarHeight}px;`" :class="{isDefault:isDefault}">
			<image v-if="show" class="back" src="@/static/arrow-left.png" @click="back"></image>
			{{title}}
			<view class="slotView">
				<slot></slot>
			</view>
		</view>
		<view class="seat" :style="`padding-top: ${statusBarHeight}px;`">
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			show: { //判断是否显示返回按钮
				default: true
			},
			title: {
				default: ""
			},
			isDefault: {
				default: false
			}
		},
		data() {
			return {
				statusBarHeight: uni.getStorageSync("statusBarHeight")
			}
		},
		methods: {
			back() {
				uni.navigateBack()
			}
		}
	}
</script>

<style lang="scss" scoped>
	.navBar {
		background: $main-color;
		height: 100rpx;
		text-align: center;
		position: fixed;
		width: 100%;
		left: 0%;
		top: 0;
		font-size: 36rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		z-index: 99;

		.back {
			width: 48rpx;
			height: 48rpx;
			position: absolute;
			left: 13rpx;
			top: 50%;
			transform: translateY(-50%);
		}
	}

	.slotView {
		position: absolute;
		top: 50%;
		transform: translateY(-50%);
		right: 30rpx;
		font-size: 28rpx;
	}

	.isDefault {
		background: #fff;
	}

	.seat {
		height: 100rpx;
	}
</style>